//package com.quyang.voice.token;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.stereotype.Component;
//import org.springframework.util.Assert;
//import org.springframework.web.cors.*;
//import org.springframework.web.filter.CorsFilter;
//import org.springframework.web.filter.OncePerRequestFilter;
//
//import javax.servlet.FilterChain;
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//@Component
//public class CorsFilters extends OncePerRequestFilter {
//    private final CorsConfigurationSource configSource;
//    private CorsProcessor processor = new DefaultCorsProcessor();
//
//    public CorsFilters(CorsConfigurationSource configSource) {
//        Assert.notNull(configSource, "CorsConfigurationSource must not be null");
//        this.configSource = configSource;
//    }
//
//
//
//
//    public void setCorsProcessor(CorsProcessor processor) {
//        Assert.notNull(processor, "CorsProcessor must not be null");
//        this.processor = processor;
//    }
//
//    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
////        CorsConfiguration corsConfiguration = this.configSource.getCorsConfiguration(request);
////        boolean isValid = this.processor.processRequest(corsConfiguration, request, response);
//        response.setHeader("Access-Control-Allow-Origin", "http://localhost:9527/");//* or origin as u prefer
//        response.setHeader("Access-Control-Allow-Credentials", "true");
//        response.setHeader("Access-Control-Allow-Methods", "PUT, POST, GET, OPTIONS, DELETE");
//        response.setHeader("Access-Control-Max-Age", "3600");
////        response.setHeader("Access-Control-Allow-Headers", "content-type, authorization");
////        if (request.getMethod().equals("OPTIONS"))
////            response.setStatus(HttpServletResponse.SC_OK);
////        else
//            filterChain.doFilter(request, response);
//
////        if (isValid && !CorsUtils.isPreFlightRequest(request)) {
////            filterChain.doFilter(request, response);
////        }
//    }
//
//}
